package com.jxb.myshop.common;

import java.util.List;

public class PageHelper<T> {
    private int page;
    private int count;
    private int pageRow;
    private int totalPage;
    private int startRow;
    private List<T> list;

    public PageHelper(int page, int count, int pageRow) {
        this.count = count;
        if (pageRow < 2){
            this.pageRow = 8;
        }else {
            this.pageRow  = pageRow;
        }
        this.totalPage = (int) Math.ceil(this.count/(this.pageRow + 0.0));
        if (page < 1){
            this.page = 1;
        }else if (page > this.totalPage){
            this.page = this.totalPage;
        }else{
            this.page = page;
        }
        this.startRow = (this.page - 1) * this.pageRow;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getPageRow() {
        return pageRow;
    }

    public void setPageRow(int pageRow) {
        this.pageRow = pageRow;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
